/**
 * @description 适用于formData和table组件共存时的公共方法和变量
 * @param {*} setData 初始化formData 
 * @returns 
 */
export default function (setData) {
  return {
    data() {
      return {
        pagination: {
          current: 1,
          showTotal: (total) => `共 ${total} 条数据`,
          onChange: (page, pageSize) => this.changePage(page, pageSize),
          total: 30,
          pageSize: 10,
          showSizeChanger: true,
          pageSizeOptions: ['10', '20', '30', '40'],
          // showQuickJumper: true
        },
        formData: {},
      };
    },
    mounted() {
      this.formData = { ...setData };
    },
    methods: {
      changePage(page, pageSize) {
        this.pagination.current = page;
        this.pagination.pageSize = pageSize;
        this.getList();
      },
      searchList() {
        this.pagination.current = 1;
        this.getList();
      },
      cleanList() {
        this.formData = { ...setData };
        this.searchList();
      },
    },
  };
}
